Skip to content

Subtype IntSet and SparseIntSet to AbstractSet{Int} - #983

Open
JohnCobbler wants to merge 1 commit into
JuliaCollections:masterfrom
JohnCobbler:fix/908-intset-abstractset
Open

Subtype IntSet and SparseIntSet to AbstractSet{Int}#983
JohnCobbler wants to merge 1 commit into
JuliaCollections:masterfrom
JohnCobbler:fix/908-intset-abstractset

Conversation

@JohnCobbler

Copy link
Copy Markdown
Contributor

Neither IntSet nor SparseIntSet subtyped AbstractSet, so generic set
algorithms and APIs that dispatch on AbstractSet ignored them.

Make both <: AbstractSet{Int} and add the helpers Base's set fallbacks need:

  • emptymutable / copymutable so filter and setdiff return the same
    concrete type instead of falling back to Set
  • filter! via unsafe_filter! (BitSet pattern) so
    intersect!(s::AbstractSet, s2::AbstractSet) works
  • delete! for SparseIntSet (was only pop!) for the filter! path
  • symdiff!(::IntSet, ::AbstractSet) and intersect!(::SparseIntSet, ::AbstractSet)
    for unambiguous dispatch

Same-type == / < / <= methods remain more specific (unchanged). Cross-type
equality with Set / between the two types becomes available via AbstractSet
fallbacks.

Docs note the AbstractSet{Int} relationship.

Fixes #908

Enable AbstractSet algorithms while keeping concrete container types.
Add emptymutable/copymutable/filter! (and SparseIntSet delete!) so
filter, setdiff, and Base's intersect!(::AbstractSet, ::AbstractSet)
stay correct. Resolve symdiff!/intersect! AbstractSet dispatch.

Fixes JuliaCollections#908
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intset doesn't subtype AbstractSet

1 participant